package com.crealth.model;

import java.io.Serializable;
import java.sql.Timestamp;

import com.alibaba.fastjson.JSONObject;
import com.crealth.utils.Utils;

public class ConsumerNextFollowupModel implements Serializable {
	private static final long serialVersionUID = 405806;

	private int id;  //客户 下次可贷款
	private int consumerID;  //客户 id
	private String loanBankName;  //可做银行
	private String loanMoney;  //可做金额
	private String loanInterestRate;  //贷款利率
	private String debtRatio;  //负债比
	private Timestamp nextLoanTm;  // 续贷时间
	
	public ConsumerNextFollowupModel() {
		id = 0;
		consumerID = 0;
		loanBankName = "";
		loanMoney = "";
		loanInterestRate = "";
		debtRatio = "";
		nextLoanTm = null;
	}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public int getConsumerID() {
		return consumerID;
	}
	public void setConsumerID(int consumerID) {
		this.consumerID = consumerID;
	}
	public String getLoanBankName() {
		return loanBankName;
	}
	public void setLoanBankName(String loanBankName) {
		this.loanBankName = loanBankName;
	}
	public String getLoanMoney() {
		return loanMoney;
	}
	public void setLoanMoney(String loanMoney) {
		this.loanMoney = loanMoney;
	}
	public String getLoanInterestRate() {
		return loanInterestRate;
	}
	public void setLoanInterestRate(String loanInterestRate) {
		this.loanInterestRate = loanInterestRate;
	}
	public String getDebtRatio() {
		return debtRatio;
	}
	public void setDebtRatio(String debtRatio) {
		this.debtRatio = debtRatio;
	}
	public Timestamp getNextLoanTm() {
		return nextLoanTm;
	}
	public void setNextLoanTm(Timestamp nextLoanTm) {
		this.nextLoanTm = nextLoanTm;
	}
	
	public void parseFromJson(JSONObject json) {
		id = Utils.getJsonIntValue(json, "id", 0);
		consumerID = Utils.getJsonIntValue(json, "consumerID", 0);
		loanBankName = Utils.getJsonString(json, "loanBankName");
		loanMoney = Utils.getJsonString(json, "loanMoney");
		loanInterestRate = Utils.getJsonString(json, "loanInterestRate");
		debtRatio = Utils.getJsonString(json, "debtRatio");
		if ( json.containsKey("nextLoanTm") ) {
			long tm = json.getLongValue("nextLoanTm") * 1000;
			nextLoanTm = new Timestamp(tm);
		}
	}
	
	public JSONObject toJSONObject() {
		JSONObject jsonObj = new JSONObject();
		jsonObj.put("id", id);
		jsonObj.put("consumerID", consumerID);
		jsonObj.put("loanBankName", loanBankName);
		jsonObj.put("loanMoney", loanMoney);
		jsonObj.put("loanInterestRate", loanInterestRate);
		jsonObj.put("debtRatio", debtRatio);
		jsonObj.put("nextLoanTm", nextLoanTm.getTime()/1000);
		
		return jsonObj;
	}
	
	
	
}
